package com.foreveross.vo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * OrderInfo entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "order_info", catalog = "hrtenement")
public class OrderInfo implements java.io.Serializable {

	// Fields

	private String id;
	private HouseUser houseUser;
	private HrHouses hrHouses;
	private Tenement tenement;
	private HrBusiness hrBusiness;
	private HrFavorable hrFavorable;
	private Integer count;
	private String outTradeNo;
	private Date chargeTime;
	private int payStatus;
	private int payType;
	private Date orderTime;

	private String payStatusName;
	private String payTypeName;
	
	
	// Constructors

	/** default constructor */
	public OrderInfo() {
	}

	/** minimal constructor */
	public OrderInfo(String id) {
		this.id = id;
	}

	/** full constructor */
	public OrderInfo(String id, HouseUser houseUser, HrHouses hrHouses,
			Tenement tenement, HrBusiness hrBusiness, HrFavorable hrFavorable,
			Integer count,String outTradeNo,
			Date chargeTime, int payStatus, int payType,
			Date orderTime) {
		this.id = id;
		this.houseUser = houseUser;
		this.hrHouses = hrHouses;
		this.tenement = tenement;
		this.hrBusiness = hrBusiness;
		this.hrFavorable = hrFavorable;
		this.count = count;
		this.outTradeNo = outTradeNo;
		this.chargeTime = chargeTime;
		this.payStatus = payStatus;
		this.payType = payType;
		this.orderTime = orderTime;
	}

	// Property accessors
	@Id
	@GenericGenerator(name="idGenerator", strategy="uuid")
	@GeneratedValue(generator="idGenerator") 
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HouseUser getHouseUser() {
		return this.houseUser;
	}

	public void setHouseUser(HouseUser houseUser) {
		this.houseUser = houseUser;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "house_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrHouses getHrHouses() {
		return this.hrHouses;
	}

	public void setHrHouses(HrHouses hrHouses) {
		this.hrHouses = hrHouses;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "tenement_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public Tenement getTenement() {
		return this.tenement;
	}

	public void setTenement(Tenement tenement) {
		this.tenement = tenement;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "business_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrBusiness getHrBusiness() {
		return this.hrBusiness;
	}

	public void setHrBusiness(HrBusiness hrBusiness) {
		this.hrBusiness = hrBusiness;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "favorable_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrFavorable getHrFavorable() {
		return this.hrFavorable;
	}

	public void setHrFavorable(HrFavorable hrFavorable) {
		this.hrFavorable = hrFavorable;
	}

	@Column(name = "count")
	public Integer getCount() {
		return this.count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}


	@Column(name = "out_trade_no")
	public String getOutTradeNo() {
		return this.outTradeNo;
	}

	public void setOutTradeNo(String outTradeNo) {
		this.outTradeNo = outTradeNo;
	}

	@Column(name = "charge_time")
	public Date getChargeTime() {
		return this.chargeTime;
	}

	public void setChargeTime(Date chargeTime) {
		this.chargeTime = chargeTime;
	}

	@Column(name = "pay_status")
	public int getPayStatus() {
		return this.payStatus;
	}

	public void setPayStatus(int payStatus) {
		this.payStatus = payStatus;
	}

	@Column(name = "pay_type")
	public int getPayType() {
		return this.payType;
	}

	public void setPayType(int payType) {
		this.payType = payType;
	}

	@Column(name = "order_time")
	public Date getOrderTime() {
		return this.orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}
	
	@Transient
	public String getPayStatusName() {
		switch (payStatus) {
			case 0:payStatusName = "未支付";break;
			case 1:payStatusName = "已支付";break;
			case 2:payStatusName = "已提货";break;
			case 3:payStatusName = "已失效";break;
			case 4:payStatusName = "已退款";break;
			case -1:payStatusName = "微信已支付,系统保存失败";break;
			default:break;
		}
		return payStatusName;
	}
	
	public void setPayStatusName(String payStatusName) {
		this.payStatusName = payStatusName;
	}
	
	@Transient
	public String getPayTypeName() {
		switch (payType) {
			case 0:payTypeName = "线下付款取货";break;
			case 1:payTypeName = "在线支付";break;
			default:break;
		}
		return payTypeName;
	}
	
	public void setPayTypeName(String payTypeName) {
		this.payTypeName = payTypeName;
	}
}